home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Interactive Reference Guide / C-C++ Interactive Reference Guide.iso / c_ref / csource3 / 113_01 / a68.doc < prev    next >
Text File  |  1985-03-11  |  36KB  |  1,315 lines

  1. /*
  2.     HEADER:        CUG113;
  3.     TITLE:        6800 Cross-Assembler (BDS C Version);
  4.     FILENAME:    A68.DOC;
  5.     VERSION:    2.6;
  6.     DATE:        07/22/1985;
  7.  
  8.     DESCRIPTION:    "This program lets you use your CP/M-80-based computer
  9.             to assemble code for the Motorola 6800, 6801, 6802,
  10.             6803, 6808, and 68701 microprocessors.  The program is
  11.             written in BDS C for the best possible performance on
  12.             8-bit machines.  All assembler features are supported
  13.             except relocation, linkage, listing control, and
  14.             macros.";
  15.  
  16.     KEYWORDS:    Software Development, Assemblers, Cross-Assemblers,
  17.             Motorola, MC6800, MC6801;
  18.  
  19.     SEE-ALSO:    CUG149, 6801 Cross-Assembler (Portable);
  20.  
  21.     SYSTEM:        CP/M-80;
  22.     COMPILERS:    BDS C;
  23.  
  24.     WARNINGS:    "This package is specifically tailored to CP/M-80
  25.             machines and the rather non-standard, but high-
  26.             performance BDS C compiler.  For other environments,
  27.             use the portable version of this package on CUG149.";
  28.  
  29.     AUTHORS:    William C. Colley III;
  30. */
  31.         6800 Cross-assembler  Rev. 2.6                          Page 1
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.                               6800 Cross-assembler
  48.  
  49.  
  50.                                     Rev. 2.6
  51.  
  52.  
  53.                Copyright (c) 1980,83,84,85 William C. Colley, III
  54.  
  55.  
  56.  
  57.                            The Manual Such As It Is.
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92.         6800 Cross-assembler  Rev. 2.6                          Page 2
  93.  
  94.  
  95.         Index
  96.  
  97.  
  98.         1    Format of Cross-assembler Commands....................... 3
  99.  
  100.              1.1  Command Strings..................................... 3
  101.              1.2  Options............................................. 3
  102.              1.3  Examples............................................ 3
  103.  
  104.         2    Format of Cross-assembler Source Files................... 5
  105.  
  106.              2.1   Statements......................................... 5
  107.              2.2   Symbols............................................ 5
  108.              2.3   Numeric Constants.................................. 6
  109.              2.4   Strings............................................ 6
  110.  
  111.         3    Expression Evaluation.................................... 8
  112.  
  113.         4    6800/6801 Instructions................................... 9
  114.  
  115.              4.1  No Argument Group................................... 9
  116.              4.2  One Argument Group.................................. 9
  117.              4.3  Two Argument Group..................................10
  118.              4.4  Branch Group........................................10
  119.              4.5  Jump Group..........................................11
  120.              4.6  Stack Group.........................................11
  121.              4.7  Pointer Group.......................................11
  122.              4.8  On Direct-page Addressing...........................11
  123.  
  124.         5    Pseudo-operations........................................13
  125.  
  126.              5.1  END.................................................13
  127.              5.2  EQU.................................................13
  128.              5.3  FCB.................................................13
  129.              5.4  FCC.................................................13
  130.              5.5  FDB.................................................13
  131.              5.6  RMB.................................................14
  132.              5.7  Conditional Assembly................................14
  133.              5.8  ORG.................................................15
  134.              5.9  SET.................................................15
  135.              5.10 CPU.................................................15
  136.  
  137.         6    Error Messages...........................................16
  138.  
  139.         7    Assembler Abort Conditions...............................18
  140.  
  141.         8    Compiling the Assembler..................................19
  142.  
  143.         9    Final Comments...........................................21
  144.  
  145.  
  146.  
  147.  
  148.  
  149.  
  150.  
  151.  
  152.  
  153.         6800 Cross-assembler  Rev. 2.6                          Page 3
  154.  
  155.  
  156.         1    Format of Cross-assembler Commands
  157.  
  158.         1.1  Command Strings
  159.  
  160.              To run the cross-assembler, type the following command line:
  161.  
  162.                   A>a68 filename options
  163.  
  164.                   filename: The   name  of  the  source  input  file   is 
  165.                             filename.68h,    the    list   can   go    to 
  166.                             filename.prn,  and  the  hex file can  go  to 
  167.                             filename.hex.
  168.  
  169.                   options:  See next section.
  170.  
  171.         1.2  Options
  172.  
  173.              The  source file comes from the currently logged disk  drive 
  174.              unless  it  is redirected by putting the string "sd" in  the 
  175.              options  field.   s  specifies the source file and  d  is  a 
  176.              device code from the following list:
  177.  
  178.                   a, b, c, d     Disk drives.
  179.                   -              The currently logged in disk drive.
  180.  
  181.              Lines  of  input containing errors will always be output  to 
  182.              the console device.  If the full listing is desired, it must 
  183.              be  called  for by putting the string "ld"  in  the  options 
  184.              field.   l specifies list file and d is a device code as per 
  185.              the source file, or one of the following:
  186.  
  187.                   x              Console device.
  188.                   y              List device.
  189.  
  190.              The hex file will not be output unless called for as per the 
  191.              list file.
  192.  
  193.              Options  must  be run together into a single string with  no 
  194.              embedded blanks.
  195.  
  196.         1.3  Examples
  197.  
  198.                   A>a68 barf          source -- a:barf.68h
  199.                                       list   -- none.
  200.                                       hex    -- none.
  201.  
  202.                   A>a68 barf sblxha   source -- b:barf.68h
  203.                                       list   -- con:
  204.                                       hex    -- a:barf.hex
  205.  
  206.                   A>a68 barf ly       source -- a:barf.68h
  207.                                       list   -- lst:
  208.                                       hex    -- none.
  209.  
  210.  
  211.  
  212.  
  213.  
  214.         6800 Cross-assembler  Rev. 2.6                          Page 4
  215.  
  216.  
  217.                   A>b:a68 barf sbh-   source -- b:barf.68h
  218.                                       list   -- none.
  219.                                       hex    -- a:barf.hex
  220.  
  221.  
  222.  
  223.  
  224.  
  225.  
  226.  
  227.  
  228.  
  229.  
  230.  
  231.  
  232.  
  233.  
  234.  
  235.  
  236.  
  237.  
  238.  
  239.  
  240.  
  241.  
  242.  
  243.  
  244.  
  245.  
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.  
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.  
  269.  
  270.  
  271.  
  272.  
  273.  
  274.  
  275.         6800 Cross-assembler  Rev. 2.6                          Page 5
  276.  
  277.  
  278.         2    Format of Cross-assembler Source Files
  279.  
  280.              Lines  of  source  input are terminated  with  CR/LF  pairs.  
  281.              Internally,  the character before the LF is discarded, so if 
  282.              the  CR is missing,  the last character of the line will  be 
  283.              eaten up.   The internal line buffer will hold a 120 charac-
  284.              ter  line.   This  may be changed by altering  the  "#define 
  285.              LINLEN  120"  statement in a68.h and recompiling the  cross-
  286.              assembler.  Excess characters in the line are thrown out.
  287.  
  288.              Lower  case  letters are converted to upper case in  as  few 
  289.              places as possible.  They are:
  290.  
  291.                   1)   In opcodes,
  292.  
  293.                   2)   In checking for keywords such as NOT, and
  294.  
  295.                   3)   In command strings.
  296.  
  297.              This means that "not",  "NOT",  "Not", etc. are all possible 
  298.              spellings of the bitwise logical inversion  operator.   This 
  299.              also  means  that  "foo" and "FOO"  are  different  symbols.  
  300.              Watch  this  if you start encountering U errors  of  symbols 
  301.              that you "know" you defined.
  302.  
  303.         2.1  Statements
  304.  
  305.              Source files input to the Cross-assembler consist of  state-
  306.              ments of the form:
  307.  
  308.                   [label] [opcode] [arguments] [;comments.]
  309.  
  310.              Labels are recognized by their beginning in column 1.  If it 
  311.              doesn't begin there,  it is assumed to be an opcode.  Labels 
  312.              are  assigned  the current program counter value unless  the 
  313.              line's opcode is "EQU" or "SET".
  314.  
  315.              Opcodes  may  be either processor instruction  mnemonics  or 
  316.              pseudo-ops.
  317.  
  318.              The  arguments  following the opcode will vary with the  op-
  319.              code.   In  the case of opcodes such as "NOP",  they may  be 
  320.              absent entirely.
  321.  
  322.              Lines terminate with either a CR/LF pair or a semicolon that 
  323.              is not embedded in a quoted string.   Anything after a semi-
  324.              colon  is ignored by the assembler,  but will appear in  the 
  325.              listing.   Note  that a semicolon in column 1 will make  the 
  326.              entire line a comment.
  327.  
  328.         2.2  Symbols
  329.  
  330.              Symbols may be of any length,  but only the first 8  charac-
  331.              ters  are significant.   This may be changed by changing the 
  332.              "#define  SYMLEN 8" statement in a68.h and  recompiling  the 
  333.  
  334.  
  335.  
  336.         6800 Cross-assembler  Rev. 2.6                          Page 6
  337.  
  338.  
  339.              assembler.  Note that this increases the storage required by 
  340.              the  symbol  table  as  each entry in the  symbol  table  is 
  341.              SYMLEN+2  bytes  in length.   The following  characters  are 
  342.              legal in a symbol:
  343.  
  344.                     A-Z  a-z  !  &  .  :  ?  [  \  ]  ^  _  `
  345.                                  {  |  }  ~  0-9
  346.  
  347.              Note that symbols may not begin with 0-9 as this would  make 
  348.              them impossible to distinguish from Intel format numbers.
  349.  
  350.              A  special  symbol * is always equal to the address  of  the 
  351.              first byte of code generated by a given line.
  352.  
  353.         2.3  Numeric Constants
  354.  
  355.              Numbers begin with 0-9, %, @, or $.  %, @, and $ are leading 
  356.              base designators for binary,  octal, and hexadecimal respec-
  357.              tively.   If the number begins with 0-9, the assembler looks 
  358.              for one of the trailing base designators B,  O,  Q, D, or H.  
  359.              If the number does not end with one of these,  it is assumed 
  360.              to be decimal.  B is the base designator for binary, O and Q 
  361.              are for octal,  D is for decimal,  and H is for hexidecimal.  
  362.              Trailing  base designators and the hex digits A-F can be  in 
  363.              either  upper  or lower case.   Note that hex  numbers  that 
  364.              start  with A-F and are specified with the designator H must 
  365.              have  a leading zero added to keep them from being  mistaken 
  366.              for symbols.  For example:
  367.  
  368.                   $ff80 and 0ff80h         evaluate to ff80 hex.
  369.                   128 and 128d             evaluate to 80 hex.
  370.                   @035, 35o, and 35q       evaluate to 1d hex.
  371.                   %0111000 and 0111000b    evaluate to 39 hex.
  372.  
  373.              A character constant is a string composed of zero,  one,  or 
  374.              two ASCII characters,  delimited by either single or  double 
  375.              quotes  ('  or  ").   Note that single quotes  only  balance 
  376.              single quotes, and double quotes only balance double quotes.  
  377.              Thus a character constant of 22 hex can be specified by '"'.  
  378.              For example:
  379.  
  380.                   "ab"           evaluates to 6162 hex.
  381.                   ""             evaluates to 0000 hex.
  382.                   "'"            evaluates to 0027 hex.
  383.                   'A'            evaluates to 0041 hex.
  384.  
  385.              Note that in the two-character character constant, the left-
  386.              hand  character will appear in the upper-order byte and  the 
  387.              right-hand character will appear in the lower-order byte.
  388.  
  389.         2.4  Strings
  390.  
  391.              Strings  are formed in the same way as  character  constants 
  392.              except  that  they may be of any length up to and  including 
  393.              255 characters.   The first character will be placed in  the 
  394.  
  395.  
  396.  
  397.         6800 Cross-assembler  Rev. 2.6                          Page 7
  398.  
  399.  
  400.              lowest-order memory byte.   A line-feed character may not be 
  401.              embedded  in  a  string as it terminates the line  and  will 
  402.              yield a quote imbalance error.   Note that strings are  only 
  403.              valid in the arguement field of an "FCC" pseudo-op.
  404.  
  405.  
  406.  
  407.  
  408.  
  409.  
  410.  
  411.  
  412.  
  413.  
  414.  
  415.  
  416.  
  417.  
  418.  
  419.  
  420.  
  421.  
  422.  
  423.  
  424.  
  425.  
  426.  
  427.  
  428.  
  429.  
  430.  
  431.  
  432.  
  433.  
  434.  
  435.  
  436.  
  437.  
  438.  
  439.  
  440.  
  441.  
  442.  
  443.  
  444.  
  445.  
  446.  
  447.  
  448.  
  449.  
  450.  
  451.  
  452.  
  453.  
  454.  
  455.  
  456.  
  457.  
  458.         6800 Cross-assembler  Rev. 2.6                          Page 8
  459.  
  460.  
  461.         3    Expression Evaluation
  462.  
  463.              The  following  operators are allowed in  expressions.   The 
  464.              operators are listed in order of precedence.
  465.  
  466.                   Unary Plus, Unary Minus
  467.  
  468.                   *, /, MOD, SHL, SHR
  469.  
  470.                   +, -
  471.  
  472.                   >, >=, <, <=, <>, =
  473.                        (These can also be written as GT,  GE, LT, LE, NE, 
  474.                        EQ.)
  475.  
  476.                   NOT       (1's complement)
  477.  
  478.                   AND       (Bitwise logical AND)
  479.  
  480.                   OR, XOR   (Bitwise logical OR and Exclusive OR)
  481.  
  482.                   HIGH, LOW
  483.  
  484.              Parentheses  are  used to change the  order  of  precedence.  
  485.              During evaluation of an expression,  as soon as a new opera-
  486.              tor is encountered that has precedence less than or equal to 
  487.              the last operator encountered,  all operations up to the new 
  488.              operator are performed.   That is,  subexpressions involving 
  489.              operators of higher precedence are computed first.
  490.  
  491.              All operators except +, -, *, /, =, <>, >=, <=, >, < must be 
  492.              separated from their operands by at least one space or tab.
  493.  
  494.              The  "HIGH mumble" is equivalent to "mumble SHR 8" and  "LOW 
  495.              mumble" is equivalent to "mumble AND $ff".
  496.  
  497.              The relational operators (=,  >,  etc.) evaluate to $ffff if 
  498.              the relationship is true, 0 if it is false.
  499.  
  500.              Expressions are terminated by commas,  semicolons,  or CR/LF 
  501.              pairs.
  502.  
  503.  
  504.  
  505.  
  506.  
  507.  
  508.  
  509.  
  510.  
  511.  
  512.  
  513.  
  514.  
  515.  
  516.  
  517.  
  518.  
  519.         6800 Cross-assembler  Rev. 2.6                          Page 9
  520.  
  521.  
  522.         4    6800/6801 Instructions
  523.  
  524.              The  instructions of the 6800 and 6801 microprocessors  fall 
  525.              into  several  catagories.   Each requires a certain set  of 
  526.              arguments and disallows all other arguments.   Arguments may 
  527.              be specified in any order and are separated by commas except 
  528.              for the register specifiers A,  B,  and X which may be  fol-
  529.              lowed by spaces or tabs.   In addition,  the register speci-
  530.              fiers  A  and  B can be attached to the end  of  the  opcode 
  531.              mnemonic with no intervening separator character.  The imme-
  532.              diate  addressing mode is specified by prefixing an  expres-
  533.              sion  with a # sign.   Blanks may be used freely  throughout 
  534.              the  argument field (except within symbols or operators such 
  535.              as NOT) to enhance the readability of the source code.   The 
  536.              basic syntax is as follows:
  537.  
  538.                   [label]   LDA  A,X,expression ;The A X and expression
  539.                                                 ;can be mixed up in any
  540.                                                 ;order.
  541.                   [label]   LDAA X,expression   ;Here, the A register
  542.                                                 ;specifier is attached
  543.                                                 ;to the opcode.
  544.  
  545.         4.1  No Argument Group
  546.  
  547.              This group contains the following opcodes:
  548.                    
  549.                   ABA       ABX *     ASLD *    CBA       CLC
  550.                   CLI       CLV       DAA       DES       DEX
  551.                   INS       INX       LSLD *    LSRD *    MUL *
  552.                   NOP       PSHX *    PULX *    RTI       RTS
  553.                   SBA       SEC       SEI       SEV       SWI
  554.                   TAB       TAP       TBA       TPA       TSX
  555.                   TXS       WAI
  556.  
  557.                   * = 6801 only
  558.  
  559.              These opcodes permit no arguments.
  560.  
  561.         4.2  One Argument Group
  562.  
  563.              This group contains the following opcodes:
  564.  
  565.                   ASL       ASR       CLR       COM       DEC
  566.                   INC       LSL *     LSR       NEG       ROL
  567.                   ROR       TST
  568.  
  569.                   * = synonym for ASL
  570.  
  571.              This group requires one argument from the following list:
  572.  
  573.                   1)   A
  574.  
  575.                   2)   B
  576.  
  577.  
  578.  
  579.  
  580.         6800 Cross-assembler  Rev. 2.6                          Page 10
  581.  
  582.  
  583.                   3)   X
  584.                        X,expression
  585.                        X expression
  586.                        expression,X
  587.  
  588.                   4)   expression
  589.  
  590.         4.3  Two Argument Group
  591.  
  592.              This group contains the following opcodes:
  593.  
  594.                   ADC       ADD       BIT       CMP       EOR
  595.                   LDA       ORA       SBC       SUB
  596.  
  597.              This  group requires an argument from each of the  following 
  598.              lists:
  599.  
  600.                   List 1:
  601.  
  602.                        1)   A
  603.  
  604.                        2)   B
  605.  
  606.                   List 2:
  607.  
  608.                        1)   X
  609.                             X expression
  610.                             X,expression
  611.                             expression,X
  612.  
  613.                        2)   expression
  614.  
  615.                        3)   #expression    (Not valid for STA.)
  616.                                            (Note that this value must be
  617.                                            in the range -128 to 255.)
  618.  
  619.         4.4  Branch Group
  620.  
  621.              This group contains the following opcodes:
  622.  
  623.                   BCC       BCS       BEQ       BGE       BGT
  624.                   BHI       BHS *     BLE       BLO **    BLS
  625.                   BLT       BMI       BNE       BPL       BRA
  626.                   BRN ***   BSR       BVC       BVS
  627.  
  628.                   * = synonym for BCC
  629.                   ** = synonym for BCS
  630.                   *** = 6801 only
  631.  
  632.              This  group  requires an expression as  its  argument.   The 
  633.              expression  evaluates  to  the address that  the  branch  is 
  634.              attempting to reach.  The destination address can be -128 to 
  635.              +127  bytes  from the address of the NEXT  instruction.   If 
  636.              this distance is exceeded, the assembler will flag an error.
  637.  
  638.  
  639.  
  640.  
  641.         6800 Cross-assembler  Rev. 2.6                          Page 11
  642.  
  643.  
  644.         4.5  Jump Group
  645.  
  646.              This group contains the following opcodes:
  647.  
  648.                   JMP       JSR
  649.  
  650.              This group requires an argument from the following list:
  651.  
  652.                   1)   X
  653.                        X expression
  654.                        X,expression
  655.                        expression,X
  656.  
  657.                   2)   expression
  658.  
  659.         4.6  Stack Group
  660.  
  661.              This group contains the following opcodes:
  662.  
  663.                   PSH       PUL
  664.  
  665.              This group requires an argument from the following list:
  666.  
  667.                   1)   A
  668.  
  669.                   2)   B
  670.  
  671.         4.7  Pointer Group
  672.  
  673.              This group contains the following opcodes:
  674.  
  675.                   ADDD *    CPX       LDD *     LDS       LDX
  676.                   STD *     STS       STX       SUBD *
  677.  
  678.                   * = 6801 only
  679.  
  680.              This group requires an argument from the following list:
  681.  
  682.                   1)   X
  683.                        X expression
  684.                        X,expression
  685.                        expression,X
  686.  
  687.                   2)   expression
  688.  
  689.                   3)   #expression    (Not valid for STD, STS, STX.)
  690.  
  691.         4.8  On Direct-page Addressing
  692.  
  693.              The assembler will select the shorter direct-page addressing 
  694.              in  preference  to  the longer extended  addressing  if  the 
  695.              expression  in the argument field meets the following  qual-
  696.              ifications:
  697.  
  698.                   1)   It  contains  no forward  references.   Note  that 
  699.  
  700.  
  701.  
  702.         6800 Cross-assembler  Rev. 2.6                          Page 12
  703.  
  704.  
  705.                        direct-page  RAM definitions should be at the  be-
  706.                        ginning of the program.
  707.  
  708.                   2)   It contains no evaluation errors such as undefined 
  709.                        symbols.
  710.  
  711.                   3)   It evaluates to a quantity in the range 0-255.
  712.  
  713.  
  714.  
  715.  
  716.  
  717.  
  718.  
  719.  
  720.  
  721.  
  722.  
  723.  
  724.  
  725.  
  726.  
  727.  
  728.  
  729.  
  730.  
  731.  
  732.  
  733.  
  734.  
  735.  
  736.  
  737.  
  738.  
  739.  
  740.  
  741.  
  742.  
  743.  
  744.  
  745.  
  746.  
  747.  
  748.  
  749.  
  750.  
  751.  
  752.  
  753.  
  754.  
  755.  
  756.  
  757.  
  758.  
  759.  
  760.  
  761.  
  762.  
  763.         6800 Cross-assembler  Rev. 2.6                          Page 13
  764.  
  765.  
  766.         5    Pseudo-operations
  767.  
  768.         5.1  END
  769.  
  770.              When  this statement is encountered,  the assembler  decides 
  771.              that the end of the source file has been reached.   If  this 
  772.              statement is missing or in a conditional assembly block that 
  773.              is not being assembled, the assembler will encounter end-of-
  774.              file on the source file.   In this case,  the assembler will 
  775.              attach an END statement and will flag an error.   The syntax 
  776.              is as follows:
  777.  
  778.                   [label]   END
  779.  
  780.              If  any  IF  statement is not closed with an  ENDI  at  this 
  781.              point, an error will be flagged.
  782.  
  783.              This statement permits no arguments.
  784.  
  785.         5.2  EQU
  786.  
  787.              This  statement  is  used to assign a permanent value  to  a 
  788.              symbol.   This  value may not be subsequently changed  by  a 
  789.              SET,  another EQU, or by writing the symbol in column 1 as a 
  790.              label.  The syntax is as follows:
  791.  
  792.                   label     EQU  expression
  793.  
  794.              A  phasing  (P) error will result if any forward  references 
  795.              are encountered in the evaluation of the expression.
  796.  
  797.         5.3  FCB
  798.  
  799.              This statement is used to place bytes in memory.   Each byte 
  800.              is defined by an expression.   Multiple bytes can be defined 
  801.              by expressions separated by commas.   If an expression eval-
  802.              uates to a quantity outside the range -128 to 255,  an error 
  803.              is flagged.  The syntax is as follows:
  804.  
  805.                   [label]   FCB  [expr1][,epxr2].....
  806.  
  807.         5.4  FCC
  808.  
  809.              This  statement  is used to place strings  in  memory.   Its 
  810.              arguments  may  only be strings.   Multiple strings  may  be 
  811.              placed  in  memory if the strings are separated  by  commas.  
  812.              The syntax is as follows:
  813.  
  814.                   [label]   FCC  [string][,string].....
  815.  
  816.         5.5  FDB
  817.  
  818.              This statement is used to place words in memory.   Each word 
  819.              is defined by an expression.   Multiple words may be defined 
  820.              by  expressions separated by commas.   Words are  placed  in 
  821.  
  822.  
  823.  
  824.         6800 Cross-assembler  Rev. 2.6                          Page 14
  825.  
  826.  
  827.              memory  with  their high-order byte in the low-order  memory 
  828.              location  and  the low-order byte in the  high-order  memory 
  829.              location.  The syntax is as follows:
  830.  
  831.                   [label]   FDB  [expr1][,expr2].....
  832.  
  833.         5.6  RMB
  834.  
  835.              This  statement  is used to reserve a block  of  memory  for 
  836.              working storage,  etc.   It requires one argument that gives 
  837.              the number of bytes of storage to reserve.  The syntax is as 
  838.              follows:
  839.  
  840.                   [label]   RMB  expression
  841.  
  842.         5.7  Conditional Assembly
  843.  
  844.              Blocks  of  code can be assembled or not assembled based  on 
  845.              the value of some expression.   The basic syntax is as  fol-
  846.              lows:
  847.  
  848.                             IF   expression
  849.  
  850.                        (lines of code)
  851.  
  852.                             ENDI
  853.  
  854.              If  the  expression  evaluates to 0,  the code will  not  be 
  855.              assembled.   The  source  lines will be  transfered  to  the 
  856.              listing,  but no hex output will be generated.
  857.  
  858.              In addition, the ELSE directive is supported as follows:
  859.  
  860.                             IF   expression
  861.  
  862.                        (lines of code)
  863.  
  864.                             ELSE
  865.  
  866.                        (more lines of code)
  867.  
  868.                             ENDI
  869.  
  870.              This is equivalent to:
  871.  
  872.                             IF   expression <> 0
  873.  
  874.                        (lines of code)
  875.  
  876.                             ENDI
  877.                             IF   expression = 0
  878.  
  879.                        (more lines of code)
  880.  
  881.                             ENDI
  882.  
  883.  
  884.  
  885.         6800 Cross-assembler  Rev. 2.6                          Page 15
  886.  
  887.  
  888.  
  889.              Note  that labels are not permitted on conditional  assembly 
  890.              directives.   Also note that an END statement can fail to be 
  891.              recognized  if it is in a conditional assembly block with  a 
  892.              false expression.
  893.  
  894.              A phasing (P) error will be flagged if there are any forward 
  895.              references in the expression.
  896.  
  897.         5.8  ORG
  898.  
  899.              This  statement  is used to load a value into  the  assembly 
  900.              program counter.  The value is obtained from the expression.  
  901.              If the expression contains forward references, a phasing (P) 
  902.              error will result.  If a label is present,  it will be EQUed 
  903.              to the new program counter value.  The syntax is:
  904.  
  905.                   [label]   ORG  expression
  906.  
  907.         5.9  SET
  908.  
  909.              This  statement  is used to assign a temporary  value  to  a 
  910.              symbol.   The  symbol  may not be redefined by an EQU or  by 
  911.              writing it in column 1 as a label,  but it may be  redefined 
  912.              by  another  SET  statement.   The value for the  symbol  is 
  913.              obtained from the expression.  If it contains forward refer-
  914.              ences, a phasing (P) error will result.  The syntax is:
  915.  
  916.                   label     SET  expression
  917.  
  918.         5.10 CPU
  919.  
  920.              This  statement  turns the 6801 opcodes on or off.   If  the 
  921.              required  expression evaluates to 6800 (decimal),  the  6801 
  922.              opcodes are turned off.   If it evaluates to 6801,  the 6801 
  923.              opcodes  are turned on.   Otherwise,  a value (V)  error  is 
  924.              flagged.  If the expression contains any forward references, 
  925.              a  phasing (P) error results.   If a 6801 opcode is  encoun-
  926.              tered  while the 6801 opcodes are turned off,  an opcode (O) 
  927.              error results.  The syntax is:
  928.  
  929.                   [label]   CPU  expression
  930.  
  931.  
  932.  
  933.  
  934.  
  935.  
  936.  
  937.  
  938.  
  939.  
  940.  
  941.  
  942.  
  943.  
  944.  
  945.  
  946.         6800 Cross-assembler  Rev. 2.6                          Page 16
  947.  
  948.  
  949.         6    Error Messages
  950.  
  951.              Error messages are flagged with a single letter in column  1 
  952.              of  the offending line in the listing.   The meaning of each 
  953.              letter follows.
  954.  
  955.                   A    The addressing mode specified (X, #) is illegal in 
  956.                        this instruction.
  957.  
  958.                   B    Distance  on  a branch instruction is  too  great.  
  959.                        Use a jump instruction with a branch around it, or 
  960.                        rearrange your code to shorten the distance.
  961.  
  962.                   D    Digit too large for the base was encountered.   In 
  963.                        particular,  watch  for 8 or 9 in an octal  number 
  964.                        and A-F in a decimal number.
  965.  
  966.                   E    Expression ill-formed.  Look for #, A, B, X embed-
  967.                        ded in an expression or like flaws.
  968.  
  969.                   I    If stack imbalance.  Look for ELSE or ENDI without 
  970.                        an IF or an IF still open at the end of the file.
  971.  
  972.                   L    Invalid label.   Label may contain invalid charac-
  973.                        ters or be equal to a reserved word like A or NOT.  
  974.                        Label  may  be present on a  conditional  assembly 
  975.                        directive.
  976.  
  977.                   M    Label multiply defined.   Label defined more  than 
  978.                        once and all definitions are not SET statements.
  979.  
  980.                   O    Invalid  opcode.   Look for misspellings,  missing 
  981.                        semicolons,  opcodes in column 1,  or 6801 opcodes 
  982.                        with 6801 opcodes are turned off.
  983.  
  984.                   P    Phasing error.   Look for expressions in ORG, EQU, 
  985.                        SET,  IF,  or CPU directives that contain  forward 
  986.                        references.   If  none exist,  something wierd  is 
  987.                        going  on  as a label that was defined in  pass  1 
  988.                        mysteriously vanished in pass 2.
  989.  
  990.                   R    A  or B specified where not allowed or not  speci-
  991.                        fied where required.
  992.  
  993.                   S    Syntax error.   Check your syntax against my  sam-
  994.                        ples.
  995.  
  996.                   T    Too  many arguments on this line.   FDB directives 
  997.                        may  only  define 127 words,  while  FCC  and  FCB 
  998.                        directives  may only define 255 bytes.   On  other 
  999.                        statements,  you  put superfluous arguments on the 
  1000.                        line.
  1001.  
  1002.                   U    Undefined  symbol  encountered  during  expression 
  1003.                        evaluation.
  1004.  
  1005.  
  1006.  
  1007.         6800 Cross-assembler  Rev. 2.6                          Page 17
  1008.  
  1009.  
  1010.  
  1011.                   V    Value out of bounds.   In particular,  FCB expres-
  1012.                        sions and 8-bit immediate values must evaluate  to 
  1013.                        -128 to 255, index values must evaluate to 0 
  1014.                        to 255, and CPU arguments must evaluate to 6800 or 
  1015.                        6801.
  1016.  
  1017.                   *    This statement generated by the assembler.   Right 
  1018.                        now,  this  only happens if you drop an END state-
  1019.                        ment or remove it through conditional assembly.
  1020.  
  1021.                   "    Quote imbalance error.   Bear in mind that '  will 
  1022.                        not  terminate  a string started with " and  vice-
  1023.                        versa.
  1024.  
  1025.                   (    Parenthesis imbalance error.  Count them!
  1026.  
  1027.  
  1028.  
  1029.  
  1030.  
  1031.  
  1032.  
  1033.  
  1034.  
  1035.  
  1036.  
  1037.  
  1038.  
  1039.  
  1040.  
  1041.  
  1042.  
  1043.  
  1044.  
  1045.  
  1046.  
  1047.  
  1048.  
  1049.  
  1050.  
  1051.  
  1052.  
  1053.  
  1054.  
  1055.  
  1056.  
  1057.  
  1058.  
  1059.  
  1060.  
  1061.  
  1062.  
  1063.  
  1064.  
  1065.  
  1066.  
  1067.  
  1068.         6800 Cross-assembler  Rev. 2.6                          Page 18
  1069.  
  1070.  
  1071.         7    Assembler Abort Conditions
  1072.  
  1073.              Under certain circumstances,  this assembler will just  give 
  1074.              up and quit in the middle of an assembly.   If you don't get 
  1075.              the error count diagnostic on the console,  read your screen 
  1076.              for sure!  The following messages occur:
  1077.  
  1078.                   1)   Can't open source.
  1079.  
  1080.                        The  source  file does not exist on the  specified 
  1081.                        disk drive.
  1082.  
  1083.                   2)   Can't open list.
  1084.                        Can't open hex.
  1085.  
  1086.                        No  directory  entries left on the disk  drive  in 
  1087.                        question.
  1088.  
  1089.                   3)   Illegal command line.
  1090.                        No file info supplied.
  1091.  
  1092.                        Bone up on command lines.
  1093.  
  1094.                   4)   If stack overflow.
  1095.  
  1096.                        IF directives may only be nested 16 deep.  Rebuild 
  1097.                        your source code to reduce your nesting depth,  or 
  1098.                        change  the  "#define  IFDEPTH  16"  statement  in 
  1099.                        a68.h and recompile the assembler.
  1100.  
  1101.                   5)   Disk read error.
  1102.  
  1103.                        Source file has a bad CRC or some other  difficul-
  1104.                        ty.
  1105.  
  1106.                   6)   Disk write error.
  1107.  
  1108.                        Out  of disk or directory space on the list or hex 
  1109.                        file.
  1110.  
  1111.                   7)   Error closing file.
  1112.  
  1113.                        Problem closing list or hex file.   You  shouldn't 
  1114.                        get this one.
  1115.  
  1116.                   8)   Symbol Table Overflow.
  1117.  
  1118.                        Your source program defines too many symbols.  The 
  1119.                        current  limit  is 500.   If you have more  memory 
  1120.                        than  I do,  you can change the  "#define  SYMBOLS 
  1121.                        500"  line in a68.h and recompile  the  assembler.  
  1122.                        Otherwise, you must work on your source code.
  1123.  
  1124.  
  1125.  
  1126.  
  1127.  
  1128.  
  1129.         6800 Cross-assembler  Rev. 2.6                          Page 19
  1130.  
  1131.  
  1132.         8    Compiling the Assembler
  1133.  
  1134.              To  compile  the assembler as it stands,  you will need  the 
  1135.              following items:
  1136.  
  1137.                   1)   40K of RAM.
  1138.  
  1139.                   2)   The BDS C Compiler Version 1.4x or 1.5x (good box, 
  1140.                        Leor!!).
  1141.  
  1142.                   3)   Digital Research's MAC macro assembler (BDS C 1.4x 
  1143.                        only).
  1144.  
  1145.                        Note:     Only  needed  if you want to  play  with          
  1146.                                  the  functions  in a68tbls.asm  as  they 
  1147.                                  exist  in a form digestible by CLINK  in 
  1148.                                  the file a68tbls.crl.
  1149.  
  1150.              To  get a68tbls.crl up from scratch with BDS C 1.4x,  you do 
  1151.              the following.  I assume everything lives on drive A.
  1152.  
  1153.                   A>b:mac a68tbls $pz sz
  1154.                   A>load a68tbls
  1155.                   A>era a68tbls.hex
  1156.                   A>era a68tbls.crl
  1157.                   A>ren a68tbls.crl=a68tbls.com
  1158.  
  1159.              With  BDS C 1.5x,  you do the following.   Again,  I  assume 
  1160.              everything lives on drive A.
  1161.  
  1162.                   A>casm a68tbls
  1163.                   A>asm a68tbls.aaz
  1164.                   A>ddt a68tbls.hex
  1165.                   -g0
  1166.                   A>save 8 a68tbls.crl
  1167.                   A>era a68tbls.hex
  1168.  
  1169.              You should now have a68tbls.crl on drive A.
  1170.  
  1171.              Now you are ready to compile the rest of the beast.
  1172.  
  1173.                   A>cc1 a68.c -e4700
  1174.                   A>cc1 a68asmln.c -e4700
  1175.                   A>cc1 a68eval.c -e4700
  1176.                   A>cc1 a68get.c -e4700
  1177.                   A>cc1 a68put.c -e4700
  1178.                   A>cc1 a68symb.c -e4700
  1179.  
  1180.              Now you can link it all together.
  1181.  
  1182.                   A>clink a68 a68asmln a68eval a68get a68put <^E>
  1183.                        a68symb a68tbls -s
  1184.  
  1185.              And, as if by magic, you've got a68.com!
  1186.  
  1187.  
  1188.  
  1189.  
  1190.         6800 Cross-assembler  Rev. 2.6                          Page 20
  1191.  
  1192.  
  1193.              Note that the linkage should all be done on one line, or bad 
  1194.              things  may happen like inadvertent pulls from DEFF.CRL  and 
  1195.              DEFF2.CRL.
  1196.  
  1197.              Note that if you have more than 40K of RAM,  you may want to 
  1198.              increase your symbol table size.  Symbols are 10 bytes each, 
  1199.              so plan accordingly.
  1200.  
  1201.  
  1202.  
  1203.  
  1204.  
  1205.  
  1206.  
  1207.  
  1208.  
  1209.  
  1210.  
  1211.  
  1212.  
  1213.  
  1214.  
  1215.  
  1216.  
  1217.  
  1218.  
  1219.  
  1220.  
  1221.  
  1222.  
  1223.  
  1224.  
  1225.  
  1226.  
  1227.  
  1228.  
  1229.  
  1230.  
  1231.  
  1232.  
  1233.  
  1234.  
  1235.  
  1236.  
  1237.  
  1238.  
  1239.  
  1240.  
  1241.  
  1242.  
  1243.  
  1244.  
  1245.  
  1246.  
  1247.  
  1248.  
  1249.  
  1250.  
  1251.         6800 Cross-assembler  Rev. 2.6                          Page 21
  1252.  
  1253.  
  1254.         9    Final Comments
  1255.              
  1256.              Happy  assembling!   If you have questions or note any bugs, 
  1257.              I'd  appreciate  a shout at (216)775-3680  after  1830  hrs. 
  1258.              Eastern time.  The questions will point up weaknesses in the 
  1259.              manual, and the bugs need to be stamped upon unmercifully.
  1260.  
  1261.  
  1262.  
  1263.  
  1264.  
  1265.  
  1266.  
  1267.  
  1268.  
  1269.  
  1270.  
  1271.  
  1272.  
  1273.  
  1274.  
  1275.  
  1276.  
  1277.  
  1278.  
  1279.  
  1280.  
  1281.  
  1282.  
  1283.  
  1284.  
  1285.  
  1286.  
  1287.  
  1288.  
  1289.  
  1290.  
  1291.  
  1292.  
  1293.  
  1294.  
  1295.  
  1296.  
  1297.  
  1298.  
  1299.  
  1300.  
  1301.  
  1302.  
  1303.  
  1304.  
  1305.  
  1306.  
  1307.  
  1308.  
  1309.  
  1310.  
  1311.  
  1312.               Page 20
  1313.  
  1314.  
  1315.              Note that the linkage should